package com.jizhi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jizhi.entity.History;
import com.jizhi.mapper.HistoryMapper;
import com.jizhi.service.HistoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 罗兆良
 * @since 2020-11-16
 */
@Service
public class HistoryServiceImpl extends ServiceImpl<HistoryMapper, History> implements HistoryService {
    @Resource
    private HistoryMapper historyMapper;

    /**
     * 病人id查询病历
     * @param page
     * @param bid
     * @return
     */
    @Override
    public List<History> selectPage(Page page, Integer bid) {
        QueryWrapper<History> wrapper=new QueryWrapper<>();
        wrapper.eq("bid",bid);
        IPage<History> historyIPage = historyMapper.selectPage(page, wrapper);
        return historyIPage.getRecords();
    }

    /**
     * 添加病历
     * @param history
     * @return
     */
    @Override
    public int getAddHistory(History history) {
        return historyMapper.insert(history);
    }


}
